<template>
  <div class="conse">
    <div class="par" v-for="item in listse()" :key="item.id" >
      <div class="title">
        <div class="logos">
          <img src="../assets/imgs/icons/ic_launcher.png" alt="" />
        </div>
        <div class="texts">
          <p>{{ item.title }}</p>
          <span v-for="(item, index) in item.tx" :key="index">{{ item }}</span>
        </div>
      </div>

      <div class="tabs">
        <div
          class="tab-img"
          v-show="flag == index"
          v-for="(item, index) in item.srcs"
          :key="index"
        >
          <img :src="item" alt="" />
        </div>
      </div>

      <div class="item">
        <p>{{ item.cons }}</p>
      </div>

      <div class="bot">
        <div class="rbtn">
          <div :class="['box', flag == '0' ? 'con' : '']" @click="flag = '0'">
            <span>中</span>
          </div>
          <div :class="['box', flag == '1' ? 'con' : '']" @click="flag = '1'">
            <span>En</span>
          </div>
        </div>
        <div class="lbtn" @click="gotfun">
          <span>{{ item.use }}</span>
        </div>
      </div>
      
    </div>
  </div>
</template>

<script>
import { getParListsJsonData } from "../api/parLists.js";
export default {
  name: "parLists",
  props: ["ids"],
  data() {
    return {
      itemsid: "",
      flag: "0",
      list: null,
    };
  },
  methods: {
    getids() {
      this.itemsid = window.localStorage.getItem("itemid");
    },
    getListFun() {
      getParListsJsonData().then((data) => {
        this.list = data.list;
      });
    },
    gotfun(){
      
      if(!(localStorage.getItem("oniu"))){
        this.$emit("gotfun",false)
      this.$router.push("creator");
      }else{
        this.$toast("已经在编辑");
        this.$emit("gotfun",false)
      }
    },
    listse() {
      if (this.list && this.itemsid) {
        return this.list.filter((item) => item.itemid == this.itemsid);
      }
      return;
    },
  },
  created() {
    this.getids();
    this.getListFun();
  },
  watch: {
    ids: function () {
      this.itemsid = this.ids;
      console.log("par", this.itemsid);
    },
  },
};
</script>

<style lang="scss" scoped>
.conse {
  .title {
    box-sizing: border-box;
    width: 100%;
    // height: 80px;
    position: fixed;
    display: flex;
    align-items: center;
    background-color: #fff;
    margin: auto;
    padding: 20px;
    border-radius: 20px;
    .logos {
      height: 60px;
      width: 60px;
      margin: 10px;
      border-radius: 10px;
      overflow: hidden;
      img {
        height: 100%;
        display: block;
      }
    }
    .texts {
      p {
        font-size: 20px;
        font-weight: 600;
      }
      span {
        display: inline-block;
        color: #999;
        height: 30px;
        line-height: 30px;
        font-size: 18px;
      }
    }
  }
  .item {
    padding: 20px;
    font-size: 16px;
    color: #999;
    padding-bottom: 50px;
    // margin-bottom: 20px;
  }
  .tabs {
    // box-sizing: border-box;
    padding: 120px 20px 0px;
    // margin-top: 110px;
    .tab-img {
      width: 100%;
      box-sizing: border-box;
      border: 1px solid #ccc;
      box-shadow: 0px 0px 5px #ccc;
      img {
        width: 100%;
        display: block;
      }
    }
  }
  .bot {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    bottom: 0px;
    right: 0px;
    left: 0px;
    margin:0 auto;
    background-color: #fff;

    .rbtn {
      width: 90px;
      height: 50px;
      background-color: #ececec;
      padding: 0px 5px;
      display: flex;
      align-items: center;
      text-align: center;
      justify-content: center;
      border-radius: 25px;
      .box {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
        background: #ececec;
        border-radius: 50%;
        color: #999;
      }
      .con {
        font-weight: 600;
        color: #333;
        background-color: #fff;
      }
    }
    .lbtn {
      width: 200px;
      margin-left: 40px;
      margin-right: auto;
      text-align: center;
      padding: 15px;
      border-radius: 30px;
      font-size: 16px;
      color: #f2f2f2;
      background-color: #fd6744;
    }
  }
}
</style>